import request from '@/utils/request'

// 基础题库列表
export function list() {
  return request({
    url: '/questions'
  })
}

// 基础题库详情
export function detail(data) {
  return request({
    url: `/questions/${data.id}`,
    data
  })
}

// 批量导入题
export function batch(data) {
  return request({
    method: 'POST',
    url: '/questions/batch',
    data
  })
}

// 基础题库添加
export function add(data) {
  return request({
    method: 'POST',
    url: '/questions',
    data
  })
}

// 基础题库修改
export function update(data) {
  return request({
    method: 'PUT',
    url: `/questions/${data.id}`,
    data
  })
}

// 基础题库删除
export function remove(data) {
  return request({
    method: 'DELETE',
    url: `/questions/${data.id}`,
    data
  })
}

// 精选题库加入取消
// export const choiceAdd = data =>
//   request(`/questions/choice/${data.id}/${data.choiceState}`, 'patch', data)
export function choiceAdd(data) {
  return request({
    method: 'POST',
    url: `/questions/choice/${data.id}/${data.choiceState}`,
    data
  })
}

// 精选题库列表
// export const choice = data => request('/questions/choice', 'get', data)
export function choice(params) {
  return request({
    url: '/questions/choice',
    params
  })
}

// 精选题库上下架
export function choicePublish(data) {
  return request({
    method: 'POST',
    url: `/questions/choice/${data.id}/${data.publishState}`,
    data
  })
}

// 试题审核
export function choiceCheck(data) {
  return request({
    method: 'POST',
    url: `/questions/check/${data.id}`,
    data
  })
}

// 试题审核意见列表
export function auditOpinions(data) {
  return request({
    url: `/questions/${data.id}/auditOpinions`,
    data
  })
}

// 出题记录
export function setRecords(data) {
  return request({
    url: `/questions/${data.id}/setRecords`,
    data
  })
}

// 组题列表
// randoms = data => createAPI('/questions/randoms', 'get', data)
// export function randoms(data) {
//   return request({
//     url: '/questions/randoms',
//     data
//   })
// }

// 组题列表删除
export function removeRandoms(data) {
  return request({
    method: 'DELETE',
    url: `/questions/randoms/${data.id}`,
    data
  })
}
